<template>
    <div class="app-container">
        <el-row :gutter="20">
            <el-col :span="24" :xs="24">
                <el-form @submit.native.prevent :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
                    <el-form-item :label="$locale('jobList.add.Student Name')" prop="studentName">
                        <el-input v-model="queryParams.studentName" :placeholder="$locale('jobList.add.Please enter the student name')" clearable style="width: 240px" @keyup.enter.native="handleQuery" />
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">{{ $locale('geWudevice.add.search for') }}</el-button>
                        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $locale('geWudevice.reset') }}</el-button>
                    </el-form-item>
                </el-form>

                <!-- <el-row :gutter="10" class="mb8">
                    <el-col :span="1.5">
                        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
                    </el-col>
                </el-row> -->

                <el-table v-loading="loading" :data="submitExceptionList">
                    <el-table-column type="index" width="50" label="序号" />
                    <el-table-column :label="$locale('geWudevice.add.Experiment Name')" align="center" key="experimentName" prop="experimentName" />
                    <el-table-column :label="$locale('jobList.add.Student ID')" align="center" key="schoolName" prop="schoolName" width="160">
                    </el-table-column>
                    <el-table-column :label="$locale('jobList.full name')" align="center" key="studentName" prop="studentName" />
                    <el-table-column :label="$locale('classList.class')" align="center" key="className" prop="className" />
                    <el-table-column :label="$locale('submitException.Warning handling before experiment')" align="center" key="startExperimentWarnHandle" prop="startExperimentWarnHandle" />
                    <el-table-column :label="$locale('submitException.Warning processing results before the experiment')" align="center" key="startExperimentWarnStatus" prop="startExperimentWarnStatus">
                        <template slot-scope="scope">
                            {{ scope.row.startExperimentWarnStatus?$locale('submitException.pass through'):$locale('submitException.Fail') }}
                        </template>
                    </el-table-column>
                    <el-table-column :label="$locale('submitException.Post experiment warning handling')" align="center" key="endExperimentWarnHandle" prop="endExperimentWarnHandle" />
                    <el-table-column :label="$locale('submitException.Warning processing results after the experiment')" align="center" key="endExperimentWarnStatus" prop="endExperimentWarnStatus">
                        <template slot-scope="scope">
                            {{ scope.row.endExperimentWarnStatus?$locale('submitException.pass through'):$locale('submitException.Fail')  }}
                        </template>
                    </el-table-column>
                    <el-table-column :label="$locale('formMarkering.list.operate')" align="center" width="160" class-name="small-padding fixed-width">
                        <!-- <template slot-scope="scope">
                            <el-button size="mini" type="text" icon="el-icon-edit" @click="handleData(scope.row)">处理</el-button>
                        </template> -->
                    </el-table-column>
                </el-table>

                <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
            </el-col>
        </el-row>

        <!-- 添加 -->
        <!-- <addDeviceList ref="addDeviceList" @getList="getList"></addDeviceList> -->
    </div>
</template>

<script>
import { getErrorListByStudentName } from "@/api/myClass/jobList";
// import addDeviceList from './add/index.vue'
import { getNames } from '@/utils/index'

// 提交异常
export default {
    name: "experiment",
    // components: { addDeviceList },
    data () {
        return {
            // 遮罩层
            loading: true,
            // 选中数组
            ids: [],
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 用户表格数据
            submitExceptionList: [],
            listData: [],
            // 弹出层标题
            title: "",
            // 部门树选项
            deptOptions: undefined,
            // 是否显示弹出层
            open: false,
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                studentName:''
            },
        };
    },
    created () {
        this.getList();
    },
    methods: {
        /** 查询用户列表 */
        getList () {
            this.loading = true;
            getErrorListByStudentName(this.queryParams).then(({ data }) => {
                this.submitExceptionList = data.records;
                this.total = data.total;
                this.loading = false;
            });
        },
        /** 搜索按钮操作 */
        handleQuery () {
            this.queryParams.pageNum = 1;
            this.getList();
        },
        /** 重置按钮操作 */
        resetQuery () {
            this.resetForm("queryForm");
            this.handleQuery();
        },
        /** 处理按钮操作 */
        handleData () {

        },
        /** 新增按钮操作 */
        handleAdd () {
            this.$refs.addDeviceList.handleAdd()
        },
        /** 修改按钮操作 */
        handleUpdate (row) {
            this.$refs.addDeviceList.handleUpdate(row)
        },
        /** 删除按钮操作 */
        handleDelete (row) {
            const userIds = row.id || this.ids;
            this.$modal.confirm(this.$locale('geWudevice.tip1') + getNames(this.submitExceptionList, userIds, 'experimentName') + this.$locale('geWudevice.tip2')).then(function () {
                return deleteById({ id: userIds });
            }).then(() => {
                this.getList();
                this.$modal.msgSuccess(this.$locale('geWudevice.tip3'));
            }).catch(() => { });

        }
    }
};
  </script>
